﻿namespace EAL.Models
{
    using System;
    using System.ComponentModel.DataAnnotations;

    public class Position : ModelBase
    {
        public event Action<Position> AmountChanged;
        public event Action<Position> ProductChanged;

        private int _id;
        private Product _product;
        private int _amount;


        [Key]
        public int Id
        {
            get { return _id; }
            set 
            { 
                _id = value;
                this.OnPropertyChanged(() => this.Id);
            }
        }

        public virtual Product Product
        {
            get { return _product; }
            set
            {
                _product = value;
                this.OnPropertyChanged(() => this.Product);
                if (this.ProductChanged != null)
                {
                    this.ProductChanged(this);
                }
            }
        }

        public int Amount
        {
            get { return _amount; }
            set 
            {
                _amount = value;

                this.OnPropertyChanged(() => this.Amount);

                if (this.AmountChanged != null)
                {
                    this.AmountChanged(this);
                }
            }
        }
    }
}
